﻿namespace WMS6.Web.TransportManagement
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class ExecutionQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnSearch;
        protected DropDownList ddlCreateBy;
        protected DropDownList ddlDeliveryDate;
        protected DropDownList ddlDispatchID;
        protected DropDownList ddlPickuPDate;
        protected DropDownList ddlPlanTransportMode;
        protected DropDownList ddlPlanTransportModeOper;
        protected DropDownList ddlShipmentCommand;
        protected DropDownList ddlStatus;
        protected DropDownList ddlStatusOper;
        protected HtmlForm F8030;
        protected HtmlInputHidden hdnActionID;
        protected HtmlHead Head1;
        protected Label lblBu;
        protected Label lblCreateBy;
        protected Label lblDeliveryDate;
        protected Label lblDispatchID;
        protected Label lblPickuPDate;
        protected Label lblPlanTransportMode;
        protected Label lblShipmentCommand;
        protected Label lblStatus;
        protected HtmlLink mycss;
        protected ScriptManager ScriptManager1;
        protected TextBox txtCreateBy;
        protected TextBox txtDeliveryDate;
        protected TextBox txtDispatchID;
        protected TextBox txtPickupDate;
        protected TextBox txtShipmentCommand;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("ExecutionList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("ExecutionList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void LoadDll()
        {
            base.BindData2DDLBySysCode(this.ddlStatusOper, "DispatchStatus");
            this.ddlStatusOper.Items.Insert(0, new ListItem("-----", ""));
            base.BindData2DDLBySysCode(this.ddlPlanTransportModeOper, "TransportMode");
            this.ddlPlanTransportModeOper.Items.Insert(0, new ListItem("-----", ""));
            base.InitQueryDDL(this.ddlDispatchID, 0);
            base.InitQueryDDL(this.ddlPickuPDate, 0);
            base.InitQueryDDL(this.ddlDeliveryDate, 0);
            base.InitQueryDDL(this.ddlPlanTransportMode, 0);
            base.InitQueryDDL(this.ddlShipmentCommand, 0);
            base.InitQueryDDL(this.ddlCreateBy, 0);
            base.InitQueryDDL(this.ddlStatus, 0);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadDll();
                if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
                {
                    this.btnExport.Visible = false;
                }
            }
        }

        public string CreateBy
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCreateBy.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCreateBy.Text.Trim(), this.ddlCreateBy.SelectedValue);
                }
                return "";
            }
        }

        public string DeliveryDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDeliveryDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDeliveryDate.Text.Trim(), this.ddlDeliveryDate.SelectedValue);
                }
                return "";
            }
        }

        public string DispatchID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDispatchID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDispatchID.Text.Trim(), this.ddlDispatchID.SelectedValue);
                }
                return "";
            }
        }

        public string PickupDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtPickupDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtPickupDate.Text.Trim(), this.ddlPickuPDate.SelectedValue);
                }
                return "";
            }
        }

        public string PlanTransportMode
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlPlanTransportModeOper.SelectedValue))
                {
                    return base.GetParamsString(this.ddlPlanTransportModeOper.SelectedValue, this.ddlPlanTransportMode.SelectedValue);
                }
                return "";
            }
        }

        public string ShipmentCommand
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtShipmentCommand.Text.Trim()))
                {
                    return base.GetParamsString(this.txtShipmentCommand.Text.Trim(), this.ddlShipmentCommand.SelectedValue);
                }
                return "";
            }
        }

        public string Status
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlStatusOper.SelectedValue))
                {
                    return base.GetParamsString(this.ddlStatusOper.SelectedValue, this.ddlStatus.SelectedValue);
                }
                return "";
            }
        }
    }
}

